package com.financial.business.integral.service.impl;

import com.financial.business.integral.constants.FinancialIntegralEnumConstants;
import com.financial.business.integral.service.FinancialIntegralQueryService;
import com.financial.business.integral.service.yd.FinancialYDIntegralPayQueryService;
import com.financial.business.integral.service.yd.FinancialYDIntegralPaymentQueryService;
import com.financial.business.integral.service.yd.FinancialYDIntegralRefundQueryService;
import com.financial.business.integral.utils.JsonUtils;
import com.financial.business.integral.utils.apiresult.ApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author WANGNING
 * @Email wyn20140226@aliyun.com
 * @Description //积分相关业务查询接口
 * @Date 2019/12/9 11:35
 */
@Service
public class FinancialIntegralQueryServiceImpl implements FinancialIntegralQueryService {
    public static final Logger logger = LoggerFactory.getLogger(FinancialIntegralQueryServiceImpl.class);

    @Autowired
    private FinancialYDIntegralPayQueryService financialYDIntegralPayQueryService;

    @Autowired
    private FinancialYDIntegralPaymentQueryService financialYDIntegralPaymentQueryService;

    @Autowired
    private FinancialYDIntegralRefundQueryService financialYDIntegralRefundQueryService;
    @Override
    public ApiResult query(String requestParam) {
        logger.info("FinancialIntegralQueryServiceImpl.query---接收积分查询参数json"+ requestParam);
        /*银盛查询*/
        Map<String, Object> condMap = JsonUtils.jsonToMap(requestParam);
        String queryType = (String) condMap.get("query_type");
        logger.info("FinancialIntegralQueryServiceImpl.query()----金融中心银盛基类，获查询付类型：" + queryType);
        ApiResult apiResult = ApiResult.failure(FinancialIntegralEnumConstants.ENUM_QUERYTYPE_ERROR);
        if (queryType.equalsIgnoreCase(FinancialIntegralEnumConstants.ENUM_QUERYTYPE_PAY)) {
            /*优店积分支付查询*/
            apiResult = financialYDIntegralPayQueryService.payQuery(requestParam);
        } else if (queryType.equalsIgnoreCase(FinancialIntegralEnumConstants.ENUM_QUERYTYPE_PAYMENT)) {
            /*优店积分银盛代付*/
            apiResult = financialYDIntegralPaymentQueryService.paymentQuery(requestParam);
        } else if(queryType.equalsIgnoreCase(FinancialIntegralEnumConstants.ENUM_QUERYTYPE_REFUND)) {
            /*优店积分退款*/
            apiResult = financialYDIntegralRefundQueryService.refundQuery(requestParam);
        }else{
            /*银盛其他查询*/
        }
        return apiResult;
    }
}
